package com.fiberhome.nas.core.ui.component.image

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CheckCircle
import androidx.compose.material.icons.filled.RadioButtonUnchecked
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.surfaceColorAtElevation
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

/**
 * 勾选框组件
 * 不要添加点击事件，会覆盖整张图片的点击事件
 * @param modifier 修饰符
 * @param selected 是否选中
 */
@Composable
fun CheckImage(
    modifier: Modifier = Modifier,
    selected: Boolean,
) {
    if (selected) {
        val bgColor = MaterialTheme.colorScheme.surfaceColorAtElevation(3.dp)
        Icon(
            Icons.Filled.CheckCircle,
            tint = MaterialTheme.colorScheme.primary,
            contentDescription = "勾选",
            modifier = modifier
                .padding(2.dp)
                .border(2.dp, bgColor, CircleShape)
                .clip(CircleShape)
                .background(bgColor)
        )
    } else {
        Icon(
            Icons.Filled.RadioButtonUnchecked,
            tint = Color.White.copy(alpha = 0.7f),
            contentDescription = "去勾选",
            modifier = modifier.padding(2.dp)
        )
    }
}